﻿#include "translation.h"
#include <QtWidgets/QApplication>
#include "Seq2SeqModel.h"
#include "Vocab.h"


int main(int argc, char *argv[])
{
    system("chcp 65001");
    QApplication a(argc, argv);

    try {
        // 加载词汇表
        Vocab src_vocab("D:/pytorch_test/pytorch_learn/translation/en_vocab.json");
        Vocab tar_vocab("D:/pytorch_test/pytorch_learn/translation/ch_vocab.json");

        // 加载模型
        Seq2SeqModel model("D:/pytorch_test/pytorch_learn/translation/ch_en_model.pth", src_vocab, tar_vocab);

        // 示例翻译
        std::cout << model.predict("afraid") << std::endl;
        std::cout << model.predict("Have you shined your shoes?") << std::endl;

    }
    catch (const std::exception& e) {
        std::cerr << "Error: " << e.what() << std::endl;
        return -1;
    }
    translation w;
    w.show();
    return a.exec();
}